package callable;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * Callable demo
 * CallAble可以抛出异常，可以有返回值
 */
public class CallableDemo {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Call call =new Call();
        FutureTask futureTask = new FutureTask(call);

        new Thread(futureTask).start();

        String s = (String) futureTask.get();
        System.out.println(s);
    }

}

class Call implements Callable<String>{

    @Override
    public String call() throws Exception {
        System.out.println("call()");
        return "call";
    }
}
